<template>
  <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" append-to-body v-dialogDrag width="90%">

    <div style="margin-bottom: 10px;">
      <el-button size="mini" icon="el-icon-warning" :plain="true"
                 @click="onButtonTestType('material_main')">材料材质</el-button>
      <el-button size="mini" icon="el-icon-warning" :plain="testType === 'sample'"
                 @click="onButtonTestType('material_assist')">材料辅材
      </el-button>
    </div>

    <div class="shadow" style="margin: 15px;border-radius: 5px;background: #fff;padding: 15px;">
      <factory-material-main-list v-if="materialType==='material_main'" :materialId="materialId" :goodsSaleId="goodsSaleId" :workOrderId="workOrderId"
                                  :rukuId="rukuId"  :goodsId="goodsId" :daohuoDetailId="daohuoDetailId"></factory-material-main-list>
      <factory-material-assist-list v-if="materialType==='material_assist'" :materialId="materialId" :goodsSaleId="goodsSaleId" :workOrderId="workOrderId"
                                    :rukuId="rukuId"   :goodsId="goodsId" :daohuoDetailId="daohuoDetailId"></factory-material-assist-list>
    </div>
  </el-dialog>
</template>

<script>
import {deleteAction, getAction, getById} from '@/api/manage'
import FactoryTestZnForm from '@/views/develop/factory/factoryTestZn/module/FactoryTestZnForm'
import FactoryMaterialMainList from "@/views/develop/factory/factoryMaterialMain/FactoryMaterialMainList.vue";
import FactoryMaterialAssistList from "@/views/develop/factory/factoryMaterialAssist/FactoryMaterialAssistList.vue";
import FactoryProductProcessList from "@/views/develop/factory/factoryProductProcess/FactoryProductProcessList.vue";
import FactoryGoodsTestSampleList from "@/views/develop/factory/factoryTestSample/FactoryGoodsTestSampleList.vue";
import FactoryGoodsTestSizeList from "@/views/develop/factory/factoryTestSize/FactoryGoodsTestSizeList.vue";
import FactoryGoodsTestZnList from "@/views/develop/factory/factoryTestZn/FactoryGoodsTestZnList.vue";
import FactoryGoodsTestMachineryHammerList
  from "@/views/develop/factory/factoryTestMachineryHammer/FactoryGoodsTestMachineryHammerList.vue";
import FactoryGoodsTestMachineryLinkList
  from "@/views/develop/factory/factoryTestMachineryLink/FactoryGoodsTestMachineryLinkList.vue";
import FactoryGoodsTestMachineryStickList
  from "@/views/develop/factory/factoryTestMachineryStick/FactoryGoodsTestMachineryStickList.vue";
import FactoryGoodsTestSurfaceList from "@/views/develop/factory/factoryTestSurface/FactoryGoodsTestSurfaceList.vue";
import FactoryGoodsProductStoreList from "@/views/develop/factory/factoryProductStore/FactoryGoodsProductStoreList.vue";

export default {
  name: "FactoryTestQualityMaterial",
  components: {
    FactoryMaterialAssistList,
    FactoryMaterialMainList,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      activeName: "first",
      // 弹出层标题
      title: "原材料质检",
      // 是否显示弹出层
      open: false,
      // 显示搜索条件
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 出厂试验-镀锌质量表格数据
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: null,
        orderId: null,
        goodsId: null,
        goodsName: null,
        goodsModel: null,
        batchNumber: null,
        productNumber: null,
        inspectTime: null,
        znThick: null,
      },
      url: {
        list: '/factoryTestZn/factoryTestZn/list',
        remove: '/factoryTestZn/factoryTestZn/',
        export: '/factoryTestZn/factoryTestZn/export',
        getMaterialById: '/factoryTestMaterial/factoryTestMaterial/',
      },
      tableMaxHeight: window.innerHeight - 320,
      isButton: 1,
      list: [],
      isIndex: 0,
      total1: 0,
      loading1: true,
      activeName1: '1',
      dataList1: [],
      materialType: 'material_main',
      produceType: 'sample',
      workOrderId: null,
      workOrder: {},
      workOrderCode: null,
      goodsId: null,
      goodsSaleId: null,
      daohuoDetailId: null,
      material:{},
      materialId:null,
      rukuId:null,
    };
  },
  created() {
    this.getList();
    window.addEventListener('resize', this.getTableHeight);
  },
  destroyed() {
    window.removeEventListener('resize', this.getTableHeight)
  },
  methods: {
    /** 查询出厂试验-镀锌质量列表 */
    getList() {
      this.loading = true;
      getAction(this.url.list, this.queryParams).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getTableHeight() {
      this.tableHeight = window.innerHeight - 320
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    onButtonTestType(type) {
      this.materialType = type;
    },


    // 到货质检
    showByDaohuoDetail(daohuo) {
      this.daohuoDetailId = daohuo.id;
      let materialId = daohuo.goods.materialMain;
      getById(this.url.getMaterialById, materialId).then(response => {
        this.material = response.data;
        this.materialType = response.data.type;
        this.materialId = response.data.id;
      });

      this.goodsSaleId = daohuo.goodsSaleId;
      this.goodsId = daohuo.goodId;
      this.open = true;
    },

    // 领料查看质检
    showByLingLiaoDetail(lingliao) {
      this.rukuId = lingliao.rukuId;
      this.goodsSaleId = lingliao.gsaleId;
      this.goodsId = lingliao.goodsId;
      this.materialId = lingliao.params.materialMainId;
      this.daohuoDetailId = lingliao.params.daohuodetailId;
      this.open = true;
    },


    handleAddMaterial() {
      if (this.materialType == null) {
        this.$message.warning("请选择原材料类型");
      }

    },

  }
};
</script>
<style scoped lang="scss">
.shadow {
  box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.05);
}

.li1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 25%;
  margin: 0 5px;
  padding: 0px 10px;
  box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.05);
  border: 1px solid #EBEEF5;
  background: #fff;
  border-radius: 5px;
  color: #333;
  transition: all .5s;
}

.li2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 25%;
  margin: 0 5px;
  padding: 0px 20px;
  box-shadow: 2px 4px 7px rgba(0, 0, 0, 0.05);
  border: 1px solid #1890ff;
  background: #e8f4ff;
  border-radius: 5px;
  color: #1890ff;
  transition: all .5s;
}

.hcss {
  font-size: 42px;
  font-weight: 700;
  background: -webkit-linear-gradient(#C0C4CC, transparent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.hcss1 {
  font-size: 42px;
  font-weight: 700;
  background: -webkit-linear-gradient(#409EFF, transparent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

::v-deep .el-collapse-item__wrap,
::v-deep .el-collapse,
::v-deep .el-collapse-item__header {
  border: none;
}

::v-deep .el-collapse-item__content {
  padding-bottom: 0;
}

.hbox {
  display: flex;
  align-items: center;
}

.hboxhcss {
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.hboxxian {
  width: 5px;
  height: 18px;
  background: #1890ff;
  margin-right: 5px;
  border-radius: 2px;
}
</style>
